﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Data.SqlClient;

/// <summary>
/// Summary description for timkiem
/// </summary>
public class timkiem
{
    DBConnection db = new DBConnection();
	public timkiem()
	{
		//
		// TODO: Add constructor logic here
		//
	}
    public DataTable load_loaihoa()
    {
        string sql = "SELECT MaLoai, TenLoai FROM Loaihoa";
        return db.Get_data(sql);
    }
    public DataTable load_dshoa(string ma,string tu,string den)
    {
        string sql = "SELECT Loaihoa.TenLoai, Hoa.GiaHoa, Loaihoa.MaLoai,Hoa.TenHoa, Hoa.YNghia, Hoa.HinhAnh, Hoa.MaHoa FROM Hoa INNER JOIN " +
                         "CTLoaiHoa ON Hoa.MaHoa = CTLoaiHoa.MaHoa INNER JOIN "+
                         "Loaihoa ON CTLoaiHoa.MaLoai = Loaihoa.MaLoai "+
                        "WHERE (Loaihoa.MaLoai = @ma) AND (Hoa.GiaHoa BETWEEN @tu AND @den)";
        SqlParameter p1=new SqlParameter ("@ma",ma);
        SqlParameter p2=new SqlParameter ("@tu",tu);
        SqlParameter p3=new SqlParameter ("@den",den);
        return db.Get_data(sql,p1,p2,p3);

    }
    public string load_loaihoa1(string ma)
    {
        string sql = "SELECT TenLoai FROM Loaihoa where MaLoai=@ma";
        SqlParameter p1 = new SqlParameter("@ma", ma);
        object kq = db.LayDuLieu(sql,p1);
        return kq.ToString();
    }
    public string load_hinhanh()
    {
        string sql = "SELECT HinhAnh FROM Hoa";
        object kq = db.LayDuLieu(sql);
        return kq.ToString();
    }
}